<template>
  <div class="delivery">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span style="line-height: 36px;">出库发运管理</span>
      </div>
      <s-table
        :table="table"
        ref="table"
        @http="tableWatch">
        <el-table-column
          fixed="right"
          align="center"
          slot="operation"
          class-name="operationMore"
          label="可用操作"
          width="200">
          <template slot-scope="s">
            <el-popover
              popper-class="demo-table-expand"
              placement="right"
              title="更多可用操作"
              trigger="click">
              <slot name="content">
                <el-button type="info"  size="mini" @click="tablePrint(s.row)">打印装车单</el-button>
                <el-button type="info"  size="mini" @click="dialogCreateOpen(s.row)" v-if="s.row.zcdbh ==='0'">创建装车单</el-button>
                <el-button type="warning"  size="mini" @click="tableShipment(s.row)" v-if="(s.row.jhzt == '1' || s.row.jhzt == '2')&& (s.row.fyzt !=='3' && s.row.fyzt!=='4')">发运</el-button>
                <el-button type="success"  size="mini" @click="tableAdditionalShipment(s.row)" v-if="s.row.fyzt =='3'">追加发运</el-button>
                <el-button type="info" size="mini" @click="dialogIssuedOpen(s.row)" v-if="(s.row.jhzt == '1' || s.row.jhzt == '2')&& (s.row.fyzt ==='1' || s.row.fyzt ==='2' ||s.row.fyzt ==='3')">下发发运任务</el-button>
                <el-button type="info" size="mini" @click="dialogSearchOpen(s.row)" v-if="(s.row.zt =='1' || s.row.zt =='2') && (s.row.fyzt =='1' || s.row.fyzt =='2' || s.row.fyzt =='3')">查看下发</el-button>
              </slot>
              <el-button slot="reference" type="info" icon="more" :plain="true" size="mini" class="__reference"></el-button>
            </el-popover> </template>
        </el-table-column>
        <el-form-item slot="multiSelect" label="多选操作" prop="multiSelect" v-if="table.multiSelect">
          <el-row>
            <el-col  :span="8">
              <el-button type="info" size="small" @click="dialogMultiOpen">多选装车单</el-button>
            </el-col>
            <el-col :span="8">
              <el-button type="info" size="small" @click="tablePrint('')">打印装车单</el-button>
            </el-col>
            <el-col :span="8">
              <el-button type="info" size="small" @click="tableShipment('')">多选发运</el-button>
            </el-col>
          </el-row>
        </el-form-item>
        <el-row>
          <el-col :xs="24" :lg="{span: 12, offset: 0}">
            <el-form-item label="波次编号" prop="bcbh">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_bcbh"
                        placeholder="波次编号" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
            <el-form-item label="发运单号" prop="fybh">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_fybh"
                        placeholder="SO编号" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
            <el-form-item label="订单号" prop="khddh">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_khddh"
                        placeholder="客户订单号" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
            <el-form-item label="客户编号" prop="khbh">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_khbh"
                        placeholder="客户编号" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
            <el-form-item label="客户名称" prop="khmc">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_khmc"
                        placeholder="客户名称" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 12, offset: 0}">
            <el-form-item label="收货地址" prop="khdz">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_khdz"
                        placeholder="客户地址" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
            <el-form-item label="路线名称" prop="xl">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_xl"
                        placeholder="路线" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
            <el-form-item label="装车单" prop="zcdbh">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_zcdbh"
                        placeholder="装车单编号" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
            <el-form-item label="交货时间" prop="yqjhsj">
              <el-date-picker
                v-model="autoVue_table_yqjhsj"
                type="daterange"
                placeholder="要求交货时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="创建时间" prop="cjsj">
              <el-date-picker
                v-model="autoVue_table_cjsj"
                type="daterange"
                placeholder="WMS创建时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </s-table>
    </el-card>
    <s-dialog :dialog="dialogCreate" :close="dialogCreateInit">
      <p slot="title">{{dialogCreate.title}}承运人</p>
      <s-form :form="formDialogCreate" ref="formDialogCreate">
        <el-row>
          <el-col :xs="24" :lg="{span: 11, offset: 0}" class="">
            <el-form-item prop="cyrmc" label="承运人">
              <el-select v-model="formDialogCreate.cyrmc"
                         filterable
                         remote
                         placeholder="请选择承运人"
                         @change="dialogRemoteCyrid"
                         :remote-method="dialogRemoteCyrmc">
                <el-option
                  v-for="item in dialogCreate.wmsloading"
                  :key="item.cyrid"
                  :label="item.cyrmc"
                  :value="item.cyrid">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 11, offset: 1}" class="">
            <el-form-item prop="cycl" label="承运车辆">
              <el-select v-model="formDialogCreate.cycl"
                         filterable
                         remote
                         @change="dialogRemoteCyclid"
                         :remote-method="dialogRemoteCycl"
                         placeholder="请选择承运车辆">
                <el-option
                  v-for="item in dialogCreate.searchCph"
                  :key="item.cyclid"
                  :label="item.cycl"
                  :value="item.cyclid">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </s-form>
      <el-button slot="footer" @click="dialogCreateSave">保存</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogIssued" :close="dialogIssuedInit">
      <p slot="title">{{dialogIssued.title}}发运任务</p>
      <s-form :form="formDialogIssued" ref="formDialogIssued">
        <el-row>
          <el-col :xs="24" :lg="{span: 11, offset: 0}" class="">
            <el-form-item prop="account" label="账户类型">
              <el-select v-model="formDialogIssued.account" placeholder="请选择">
                <el-option
                  v-for="item in SHELVESTASK.account"
                  :key="item.dictionaryid"
                  :label="item.value"
                  :value="item.dictionaryid">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 11, offset: 1}" class="">
            <el-form-item prop="ryid" label="人员">
              <el-select v-model="formDialogIssued.ryid"
                         filterable
                         @change="dialogRemoteryid"
                         placeholder="请输入人员名称">
                <el-option
                  v-for="item in dialogIssued.wmsqualityinspectionlist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </s-form>
      <el-button slot="footer" @click="dialogIssuedSave">保存</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogSearch" :close="dialogSearchInit">
      <s-table :table="tableSearch" ref="tableSearch" @http="tableWatch"></s-table>
    </s-dialog>
    <s-dialog :dialog="dialogMulti" :close="dialogMultiInit">
      <p slot="title">{{dialogMulti.title}}承运人</p>
      <s-form :form="formDialogMulti" ref="formDialogMulti">
        <el-row>
          <el-col :xs="24" :lg="{span: 11, offset: 0}" class="">
            <el-form-item prop="cyrmc" label="承运人">
              <el-select v-model="formDialogMulti.cyrmc"
                         filterable
                         remote
                         placeholder="请选择承运人"
                         @change="dialogRemoteCyrid"
                         :remote-method="dialogRemoteCyrmc">
                <el-option
                  v-for="item in dialogCreate.wmsloading"
                  :key="item.cyrid"
                  :label="item.cyrmc"
                  :value="item.cyrid">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 11, offset: 1}" class="">
            <el-form-item prop="cycl" label="承运车辆">
              <el-select v-model="formDialogMulti.cycl"
                         filterable
                         remote
                         @change="dialogRemoteCyclid"
                         :remote-method="dialogRemoteCycl"
                         placeholder="请选择承运车辆">
                <el-option
                  v-for="item in dialogCreate.searchCph"
                  :key="item.cyclid"
                  :label="item.cycl"
                  :value="item.cyclid">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </s-form>
      <el-button slot="footer" @click="dialogMultiSave">保存</el-button>
    </s-dialog>
  </div>
</template>

<script>
  import {AutoVue, AutoPromise, GetLodop, FormatterTime} from '~/plugins/Tools';
  function __formCreate () {
    return {
      cyrmc: { value: '', rule: [ 'vNull__change' ] },
      cycl: { value: '', rule: [ 'vNull__change' ] },
    };
  }
  function __formMulti () {
    return {
      cyrmc: { value: '', rule: [ 'vNull__change' ] },
      cycl: { value: '', rule: [ 'vNull__change' ] },
    };
  }
  function __formIssued () {
    return {
      account: { value: '', rule: [ 'vNull__change' ] },
      ryid: { value: '', rule: [ 'vNull__change' ] },
    };
  }
  export default AutoVue({
    name: 'outOperation_shipment-FEcarWms',
    head: {
      'title': '出库发运管理',
      'meta': [
        { 'hid': 'description', 'name': 'description', 'content': '乐速科技平台 出库发运 查看出库发运信息' },
      ],
    },
    store: ['DICTIONARY_shelvesTask', 'SHELVESTASK'],
    data: {
      table: {
        column: [
          { label: '客户创建时间',
            prop: 'khcjsj',
            minWidth: '0px',
            cRemarks: '',
            formatter: (row, column) => {
              return this.a.methods.formatterTime(row[column.property || column], 6);
            },
            type: 'DateRange',
            search: true },
          { label: 'wms创建时间',
            prop: 'cjsj',
            minWidth: '0px',
            cRemarks: '',
            formatter: (row, column) => {
              return this.a.methods.formatterTime(row[column.property || column], 6);
            },
            type: 'DateRange',
            search: true },
          { label: 'SO编号',
            prop: 'fybh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '客户订单号',
            prop: 'khddh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '装车单编号',
            prop: 'zcdbh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '订单类型',
            prop: 'show_fylx',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '交货方式',
            prop: 'show_jhfs',
            minWidth: '0px',
            cRemarks: '0、发运 1、自提',
            search: true },
          { label: 'SO状态',
            prop: 'show_fyzt',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '客户编号',
            prop: 'khbh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '客户名称',
            prop: 'khmc',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '联系人',
            prop: 'lxrxm',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '收货地址',
            prop: 'khdz',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '审核状态',
            prop: 'show_shzt',
            minWidth: '0px',
            cRemarks: '0、未审核 1、已审核',
            search: true },
          { label: '拆单状态',
            prop: 'show_cdzt',
            minWidth: '0px',
            cRemarks: '0、未拆单 1、已拆单',
            search: true },
          { label: '装箱状态',
            prop: 'show_zxzt',
            minWidth: '0px',
            cRemarks: '0、未装箱 1、部分装箱 2、全部装箱',
            search: true },
          { label: '波次状态',
            prop: 'show_bczt',
            minWidth: '0px',
            cRemarks: '0、未加入 1、已加入',
            search: true },
          { label: '拣货状态',
            prop: 'show_jhzt',
            minWidth: '0px',
            cRemarks: '0、初始 1、部分拣货 2、全部拣货',
            search: true },
          { label: '波次编号',
            prop: 'bcbh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '路线名称',
            prop: 'xl',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '交货时间',
            prop: 'yqjhsj',
            minWidth: '0px',
            cRemarks: '',
            formatter: (row, column) => {
              return this.a.methods.formatterTime(row[column.property || column], 6);
            },
            type: 'DateRange',
            search: true },
        ],
        url: '/wmsloading/list',
        key: 'id',
        popover: {
          width: 600,
        },
        tableColumn: 6,
      },
      dialogCreate: {
        title: '选择',
        wmsloading: [],
        searchCph: [],
        row: {},
      },
      formDialogCreate: __formCreate(),
      dialogIssued: {
        title: '下发',
        wmsqualityinspectionlist: '',
        row: {},
        ryid: '',
      },
      formDialogIssued: __formIssued(),
      dialogSearch: {
        title: '查看',
        size: 'large',
      },
      tableSearch: {
        column: [
          { label: '装车单单号',
            prop: 'zcdbh',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '承运人',
            prop: 'cyr',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '线路名称',
            prop: 'xlmc',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '集货库位',
            prop: 'kwmc',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '发运编号',
            prop: 'fybh',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '客户名称',
            prop: 'khmc',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '联系人',
            prop: 'lxr',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '客户地址',
            prop: 'khdz',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '货品编号',
            prop: 'hpbh',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '货品名称',
            prop: 'hpmc',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '包装数量',
            prop: 'bzsl',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '数量',
            prop: 'sjsl',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '主单位描述',
            prop: 'zdwms',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '箱单位描述',
            prop: 'xdwms',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '作业人员',
            prop: 'zyrymc',
            minWidth: '0px',
            cRemarks: '',
            search: false },
        ],
        option: {
          fyid: '',
        },
        url: '/wmspdashipment/list',
        key: 'id',
        muti: false,
        popover: {
          width: 600,
        },
        tableColumn: 6,
      },
      dialogMulti: {
        title: '选择',
        wmsloading: [],
        searchCph: [],
        row: {},
      },
      formDialogMulti: __formMulti(),
    },
    transition: 'slide-fade',
    methods: {
      formatterTime: FormatterTime,
      async tablePrint (row) {
        console.log('test');
        let ids = [];
        let index = 0;
        let trs = [''];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        try {
          let {contentList} = await this.post('/wmsloading/printLoading', {
            ids,
          });
          for (let j = 0; j < contentList.length; j++) {
            for (let i = 0; i < contentList[j].wmsLoadingDetailedList.length; i++) {
              trs[j] += `
                  <tr>
                    <td width="50px"  style="border: 1px solid #000;height:18px"><b>${i + 1}</b></td>
                    <td width="180px" style="border: 1px solid #000;height:18px"><b>${contentList[j].wmsLoadingDetailedList[i].wlbh}</b></td>
                    <td width="180px" style="border: 1px solid #000;height:18px"><b>${contentList[j].wmsLoadingDetailedList[i].xbh}</b></td>
                    <td width="180px" style="border: 1px solid #000;height:18px"><b>${contentList[j].wmsLoadingDetailedList[i].shr}</b></td>
                  </tr>`;
            }
          }
          this.$confirm('您将打印装车单信息。', '确认打印？', {
            confirmButtonText: '是',
            cancelButtonText: '否',
            type: 'warning',
          }).then(() => {
            let LODOP = GetLodop();
            LODOP.PRINT_INIT('打印装车单信息');
            // console.log('1:' + JSON.stringify(contentList[0].wmsLoadingDetailedList.length));
            for (let item of contentList) {
              LODOP.NewPage();
              LODOP.ADD_PRINT_TEXT(51, 261, 268, 42, '大连双迪发运装载单');
              LODOP.SET_PRINT_STYLEA(0, 'FontSize', 20);
              LODOP.SET_PRINT_STYLEA(0, 'Horient', 2);
              LODOP.ADD_PRINT_BARCODE(120, 230, 400, 78, 'EAN128B', item.zcdbh);
              LODOP.SET_PRINT_STYLEA(0, 'Horient', 2);
              LODOP.ADD_PRINT_TEXT(235, 123, 160, 24, '物流单数');
              LODOP.ADD_PRINT_TEXT(235, 188, 160, 24, item.zds);
              LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
              LODOP.ADD_PRINT_TEXT(286, 123, 160, 25, '承运商');
              LODOP.ADD_PRINT_TEXT(286, 188, 160, 25, item.cyrmc);
              LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
              LODOP.ADD_PRINT_TEXT(233, 327, 252, 25, '总箱数');
              LODOP.ADD_PRINT_TEXT(233, 392, 252, 25, item.zxs);
              LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
              LODOP.ADD_PRINT_TEXT(285, 325, 254, 25, '承运车辆');
              LODOP.ADD_PRINT_TEXT(282, 390, 254, 25, item.cycl);
              LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
              LODOP.ADD_PRINT_TABLE(334, 125, 500, 280, `<table border=0 cellSpacing=0 cellPadding=0  width="100%">
                  <tr>
                    <td width="50px"  style="border: 1px solid #000;height:18px"><b>序号</b></td>
                    <td width="180px" style="border: 1px solid #000;height:18px"><b>物流单号</b></td>
                    <td width="180px" style="border: 1px solid #000;height:18px"><b>箱编号</b></td>
                    <td width="180px" style="border: 1px solid #000;height:18px"><b>收货人</b></td>

                  </tr>` +
                trs[index] + `<tfoot>
                  <tr>
                  <th colspan="2" style="border: none; height: 50px">双迪代表</th>
                  <th colspan="2" style="border: none; height: 50px">承运人</th>
                  </tr>
                   <tr>
                  <th colspan="2" style="border: none; height: 50px">日期</th>
                  <th colspan="2" style="border: none; height: 50px">日期</th>
                  </tr>

                  </tfoot></table>`);
              LODOP.ADD_PRINT_TEXT(233, 599, 169, 25, '打印日期');
              LODOP.ADD_PRINT_TEXT(230, 660, 169, 25, this.formatterTime(new Date(), 3));
              LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
              // LODOP.ADD_PRINT_TEXT(385, 123, 257, 24, '双迪代表');
              // LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
              // LODOP.ADD_PRINT_TEXT(550, 123, 259, 20, '日期');
              // LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
              // LODOP.ADD_PRINT_TEXT(500, 450, 238, 20, '承运人');
              // LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
              // LODOP.ADD_PRINT_TEXT(550, 450, 238, 20, '日期');
              // LODOP.SET_PRINT_STYLEA(0, 'FontSize', 11);
              index++;
            }
            // CreatePrintPage();
            // 设计
            // LODOP.PRINT_DESIGN();
            LODOP.PREVIEW();
          });
        } catch (err) {
          console.log(err);
        };
      },
      async tableShipment (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        let json = await this.post('/wmspicking/dataJudgment', {
          ids,
        });
        if (json === 1) {
          this.$confirm('您还有未拣货的数据,是否继续进行发运？？？', '是否发运？', {
            confirmButtonText: '是',
            cancelButtonText: '否',
            type: 'warning',
          })
            .then(async _ => {
              try {
                await this.post('/wmspicking/despacth', {
                  ids,
                });
                this.tableWatch('table');
              } catch (err) {
                console.log(err);
              }
            });
        } else {
          this.$confirm('您将发运选择的发运订单', '确认发运？', {
            confirmButtonText: '是',
            cancelButtonText: '否',
            type: 'warning',
          })
            .then(async _ => {
              try {
                await this.post('/wmspicking/despacth', {
                  ids,
                });
                this.tableWatch('table');
              } catch (err) {
                console.log(err);
              }
            });
        }
        /*
        this.$confirm('您将发运选择的发运订单', '确认发运？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmspicking/despacth', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          });
          */
      },
      tableAdditionalShipment (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将追加发运选择的发运订单', '确认追加发运？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmspicking/despacthAdd', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          });
      },

      dialogCreateInit () {
        this.formDialogCreate = {
          ...this.formDialogCreate,
          ...this.ObjectClone(__formCreate()),
        };
        this.resetFields('formDialogCreate');
      },
      async dialogCreateOpen (row) {
        await AutoPromise([
          async () => {
            if (this.dialogCreate.wmsloading.length === 0) {
              this.dialogCreate.wmsloading = await this.post('/wmsloading/searchCyr', {
              });
            }
          },
        ]);
        this.dialogCreate.row = row;
        this.dialogCreate.visible = true;
      },
      async dialogRemoteCyrmc (query) {
        this.dialogCreate.wmsloading = await this.post('/wmsloading/searchCyr', {cyrmc: query});
      },
      async dialogRemoteCycl (query, id) {
        this.dialogCreate.searchCph = await this.post('/wmsloading/searchCph', { cyrid: this.dialogCreate.row.cyrid, cph: query });
      },
      async dialogRemoteCyrid () {
        this.dialogCreate.wmsloading.forEach(value => {
          this.dialogCreate.row.cyrid = value.cyrid;
          this.dialogCreate.row.cyrmc = value.cyrmc;
          console.log('id:' + this.dialogCreate.row.cyrid);
        });
        let str = '';
        this.dialogCreate.searchCph = await this.post('/wmsloading/searchCph', { cyrid: this.dialogCreate.row.cyrid, cph: str });
      },
      async dialogRemoteCyclid (id) {
        this.dialogCreate.searchCph.forEach(value => {
          this.dialogCreate.row.cycl = value.cycl;
          console.log('value.cycl:' + value.cycl);
          this.dialogCreate.row.cyclid = value.cyclid;
        });
      },
      async dialogCreateSave () {
        this.VALIDATE('formDialogCreate', async option => {
          option.cyrid = this.dialogCreate.row.cyrid;
          option.cyrmc = this.dialogCreate.row.cyrmc;
          option.cycl = this.dialogCreate.row.cycl;
          let json = {
            ...option,
            wmsLoadingDetailedList: [
              {
                fyid: this.dialogCreate.row.id,
              },
            ],
          };
          try {
            await this.post('/wmsloading/addLoading', json);
            this.tableWatch('table');
            this.dialogCreateInit();
            this.dialogCreate.visible = false;
          } catch (err) {
            console.log(err);
          }
        });
      },

      dialogMultiInit () {
        this.formDialogMulti = {
          ...this.formDialogMulti,
          ...this.ObjectClone(__formMulti()),
        };
        this.resetFields('formDialogMulti');
      },
      async dialogMultiOpen (row) {
        await AutoPromise([
          async () => {
            if (this.dialogCreate.wmsloading.length === 0) {
              this.dialogCreate.wmsloading = await this.post('/wmsloading/searchCyr', {
              });
            }
          },
        ]);
        this.dialogMulti.visible = true;
      },
      async dialogMultiSave () {
        this.VALIDATE('formDialogMulti', async option => {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('请至少选择一条单据！', '提示');
          }
          let wmsLoadingDetailedList = [];
          this.table.multipleSelection.forEach(({id}) => {
            wmsLoadingDetailedList.push({'fyid': id});
          });
          option.wmsLoadingDetailedList = wmsLoadingDetailedList;
          try {
            option.cyrid = this.dialogCreate.row.cyrid;
            option.cyrmc = this.dialogCreate.row.cyrmc;
            option.cycl = this.dialogCreate.row.cycl;
            await this.post('/wmsloading/addLoading', option);
            this.tableWatch('table');
            this.dialogMultiInit();
            this.dialogMulti.visible = false;
          } catch (err) {
            console.log(err);
          }
        });
      },
      dialogIssuedInit () {
        this.formDialogIssued = {
          ...this.formDialogIssued,
          ...this.ObjectClone(__formIssued()),
        };
        this.resetFields('formDialogIssued');
      },

      async dialogIssuedOpen (row) {
        await AutoPromise([
          async () => {
            if (!this.DICTIONARY_shelvesTask) {
              await this.USE('DICTIONARY_shelvesTask');
            }
          },
        ]);
        this.dialogIssued.row = row;
        console.log('id:' + this.dialogIssued.row.id);
        this.dialogIssued.visible = true;
      },
      async dialogRemoteryid (id) {
        this.dialogIssued.wmsqualityinspectionlist.forEach(value => {
          if (id === value.id) {
            this.dialogIssued.row.userName = value.name;
          }
        });
      },
      dialogIssuedSave () {
        if (this.formDialogIssued.account === '0') {
          this.VALIDATE('formDialogIssued', async option => {
            delete option.account;
            option.zyryid = option.ryid.toString();
            delete option.ryid;
            option.zyrymc = this.dialogIssued.row.userName;
            option.fyid = this.dialogIssued.row.id;
            let step = [];
            step.push(option);
            try {
              await this.post('/wmspdashipment/addPda', step);
              this.dialogIssuedInit();
              this.tableWatch('table');
              this.dialogIssued.visible = false;
            } catch (err) {
              console.log(err);
            }
          });
        } else {
          this.VALIDATE('formDialogIssued', async option => {
            delete option.account;
            option.zyryid = option.ryid.toString();
            delete option.ryid;
            option.zyrymc = this.dialogIssued.row.userName;
            option.fyid = this.dialogIssued.row.id;
            let step = [];
            step.push(option);
            try {
              await this.post('/wmspdashipment/addPda', step);
              this.dialogIssuedInit();
              this.tableWatch('table');
              this.dialogIssued.visible = false;
            } catch (err) {
              console.log(err);
            }
          });
        }
      },
      dialogSearchInit () {},
      dialogSearchOpen (row) {
        this.tableSearch.url = '/wmspdashipment/list';
        this.tableSearch.option.fyid = row.id;
        this.tableWatch('tableSearch');
        this.dialogSearch.visible = true;
      },
    },
    watch: {
      'formDialogIssued.account': async function (account) {
        this.formDialogIssued.ryid = '';
        if (account.length !== 0 && account === '0') {
          this.dialogIssued.wmsqualityinspectionlist = await this.post('/wmsqualityinspectionlist/selectYh', {});
        }
        if (account.length !== 0 && account === '1') {
          let {contentList} = await this.post('/wmsqualityinspectionlist/selectPDADLByHz', {
          });
          this.dialogIssued.wmsqualityinspectionlist = contentList;
        }
      },
    },
    mounted: function () {
      console.log('delivery.vue');
      this.tableWatch('table');
    },
  });
</script>
<style scoped lang="scss">
  table, th{
    border:none;
    height: 100px;
  }
  .box-card {
    margin: 20px;
  }

  .createTimeSpan {
    display: block;
    margin-top: 34px;
  }

  @media screen and (max-width: 800px) {
    .createTimeSpan {
      margin-top: 0;
    }
    .box-card {
      margin: 0;
    }
  }

  .el-select {
    width: 100%;
  }
</style>

<style lang="scss">
</style>
